<?php
class Williams_Favourite_Lighting {
	function Williams_Favourite_Lighting() {
		$image_directory = 'data/_uploaded/image/williams_favourite_lighting';
		$thumbnail_directory = 'data/_uploaded/image/thumbnails/image/williams_favourite_lighting';
		
		/**
		* Grab a list of all the files in the gallery directory.
		*/
		$files = scanndir($image_directory);
		
		/**
		* Filter the files so we only have images.
		*/
		function is_image($filename) {
			$image_extensions = array('jpg', 'jpeg', 'png', 'gif');
			$info = pathinfo($filename);
			return in_array($info['extension'], $image_extensions);
		}
		
		$images = array_filter($files, 'is_image');
		
		/**
		* Loop through the array, build the path for the thumbnail and the image, then output
		* the image to the screen.
		*/
		foreach ($images as $image) {
			$thumbnail_path = $thumbnail_directory . '/' . $image . '.jpg';
			$image_path = $image_directory . '/' . $image;
			
			printf('<a name="gallery" href="%"><img src="%" alt="%s" /></a>', $image_path, $thumbnail_path, $image);
		}
	}
}
?>